<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script src="./js/vue.js"></script>
</head>

<body>
    <div id="app">
        <button @click="showInputBox">显示输入框</button>
        <input type="text" ref="inp" v-if="isShow">
    </div>

    <script>
        new Vue({
            el: '#app',
            data: {
                isShow: false
            },
            methods: {
                showInputBox: function () {
                    this.isShow = !this.isShow;
                    if (this.isShow) {
                        this.$nextTick(() => {
                            this.$refs.inp.focus()
                        })
                    }
                }
            }
        })
    </script>
</body>

</html>